package spittr.web;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import org.junit.Test;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
import org.springframework.test.web.servlet.result.MockMvcResultMatchers;
import org.springframework.test.web.servlet.setup.MockMvcBuilders;

import spittr.data.Spittle;

public class HomeControllTest {

	@Test
	public void testHomePage() throws Exception{
		HomeController controller = new HomeController();
		
		System.out.println("testHomePage");
		
		MockMvc mockMvc = MockMvcBuilders.standaloneSetup(controller).build();
		
		mockMvc.perform(MockMvcRequestBuilders.get("/")).andExpect(MockMvcResultMatchers.view().name("home"));
		

		
	}
	
	@Test
	public void shouldShowRecentSpittles(){
		List<Spittle> spittleList = createSpittleList(20);
	}
	
	private List<Spittle> createSpittleList(int num) {
		List<Spittle> list = new ArrayList<>();

		for (int i = 0; i < num; i++) {
			list.add(new Spittle("spittle" + i, new Date()));
		}
		return list;
	}

}
